package com.wnhoo.smartfishtank.api.data;


import com.wnhoo.smartfishtank.util.Function;

/**
 * Created by kevinwen on 2014/11/16.
 * Copyright (c) 2014/11/16.KevinWen. All rights reserved.
 */
public class DataTiming {
    private boolean status_open ;//定时开是“开”还是“关”
    private boolean status_colse ;
    private String time_open ;//开定时的时间,如12:50
    private String time_colse ;
    private String perion_value;//定时的星期和是否开关
    private boolean power;
    private String color;//颜色
    private boolean send_timing;//当前是设置了定时的，还是空

    public boolean isSend_timing() {
        return send_timing;
    }

    public void setSend_timing(boolean send_timing) {
        this.send_timing = send_timing;
    }

    public String getColor() {
        return color;
    }

    public void setColor(String color) {
        this.color = color;
    }

    @Override
    public String toString() {
        return "DataTiming{" +
                "status_open=" + status_open +
                ", status_colse=" + status_colse +
                ", time_open='" + time_open + '\'' +
                ", time_colse='" + time_colse + '\'' +
                ", perion_value='" + perion_value + '\'' +
                ", power=" + power +
                ", color='" + color + '\'' +
                ", send_timing=" + send_timing +
                '}';
    }

    /**
     * DataTiming实例转为协议格式数据【01,1,15:46,FF;01,0,15:47,FF】
     * @return 两组定时数组（定时开/定时关）
     */
    public String toData() {
        //一组数据1（2;FFFFFF,08:00,09:30,FF; FFFF00,09:30,10:30,FF;）
        StringBuffer sb = new StringBuffer();
        sb.append(getColor()).append(",").append(getTime_open()).append(",").
                append(getTime_colse()).append(",").append(getPerion_value());
        return sb.toString();
    }

    /**
     * 获取十六进制的重复周期
     * @return String
     */
    public String getPerionValueHexString(boolean status){

        String temp = null;
        if(!power){
            //如果总开关是关闭的，那么，定时开/定时关的使能都是0
            //只有总开关是开启的，才使用定时开/定时关的使能
            temp = "0"+getPerion_value();
        }else if(status){
            temp = "1"+getPerion_value();
        }else {
            temp = "0"+getPerion_value();
        }
        return Function.String2ToHexString(temp);
    }

    public boolean isStatus_open() {
        return status_open;
    }

    public void setStatus_open(boolean status_open) {
        this.status_open = status_open;
    }

    public boolean isStatus_colse() {
        return status_colse;
    }

    public void setStatus_colse(boolean status_colse) {
        this.status_colse = status_colse;
    }

    public String getTime_open() {
        return time_open;
    }

    public void setTime_open(String time_open) {
        this.time_open = time_open;
    }

    public String getTime_colse() {
        return time_colse;
    }

    public void setTime_colse(String time_colse) {
        this.time_colse = time_colse;
    }

    public String getPerion_value() {
        return perion_value;
    }

    public void setPerion_value(String perion_value) {
        this.perion_value = perion_value;
    }

    public boolean isPower() {
        return power;
    }

    public void setPower(boolean power) {
        this.power = power;
    }
}
